package cn.kgc.vue.controller;

import cn.kgc.vue.commons.QueryCondition;
import cn.kgc.vue.entity.LogInfo;
import cn.kgc.vue.response.ResponseResult;
import cn.kgc.vue.service.LogInfoService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author 课工场
 * @date 2024/10/8
 * @description
 */
@RestController
@RequestMapping("logs")
public class LogInfoController {

    @Resource
    private LogInfoService logInfoService;

    @PostMapping("page")
    public ResponseResult logsPage(@RequestBody QueryCondition<LogInfo> queryCondition){

       return logInfoService.logsPage(queryCondition);
    }


    // 删除日志
    @DeleteMapping("delete")
    public ResponseResult deleteLogs(@RequestBody List<Integer> ids){
        logInfoService.removeBatchByIds(ids);
        return ResponseResult.success();
    }

    // 导出日志
    @PostMapping("export")
    public void  exportLogs(@RequestBody Map<String,String> params, HttpServletResponse response){

        logInfoService.exportLogs(params,response);

    }

}
